package com.atguigu.chaptar1

object Test55 {
  /*
 5、根据指定规则对数组所有元素聚合
 Array(10,4,6,10,2)
 规则: 求和/求乘积
 结果: 32
  */
  def main(args: Array[String]): Unit = {
    val arr = Array(10,4,6,10,2)
    val func=(x:Int,y:Int)=>{x+y}
    println(haha(arr, _ * _))
  }
  def haha(arr:Array[Int],func:(Int,Int)=>Int)={
    var tmp = arr(0)
    for(a<-1 until arr.length){
      tmp = func(tmp,arr(a))
    }
    tmp
  }
}
